<template>
  <ul class="themeNav">
    <li v-for="(type, idx) in types" :key="idx"
    @click="changeIdx(idx)" :class="{colorBlue: this.typeIdx===idx}">
      {{types[idx]}}
      <div></div>
    </li>
  </ul>
</template>

<script>
export default {
  data() {
    return {
      types: ['综合', '数理', '语言', '开发', '算法', '其他']
    }
  },
  computed: {
    typeIdx() {
      return parseInt(this.$route.query.t) || 0;
    }
  },
  methods: {
    changeIdx(idx) {
      this.idx = idx;
      this.$router.push({
        path: this.$route.path,
        query: {
          ...this.$route.query,
          t: idx
        }
      })
    }
  },
  mounted () {
  },
}
</script>

<style scoped lang="less">
.themeNav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  width: var(--themeNavWidth);
  height: var(--themeNavHeight);
  background-color: white;

  li {
    position: relative;
    flex-grow: 1;
    padding: 0 20px;
    font-size: 17px;
    line-height: var(--themeNavHeight);
    text-align: center;

    &:hover {
      color: var(--blue);
      cursor: pointer;

      div {
        width: 40%;
      }
    }

    div {
      position: absolute;
      bottom: 0;
      left: 50%;
      transform: translateX(-50%);
      width: 0;
      height: 4px;
      background-color: var(--darkBlue);
      transition: .2s;
    }
  }
}
</style>